import { type ResType } from "./shared"
import { request } from "../utils"
const URL = 'takeAway_address'

export type ResponseGetAddress = {
    affectedDocs: number, //条数
    code: number, //0为没错误
    data: addressItem[],
   msg?:string
}
export type addressItem = {
    address: string
    is_default: boolean
    mobile: string
    name: string
    user_id: string
    _id: string
}
export const getOneAddressAPI = (id:string) => {
    return request<ResponseGetAddress>({
        method: 'GET',
        url: `${URL}/getAddress?id=${id}`
    })
}


export const getAddressAPI = () => {
    return request<ResponseGetAddress>({
        method: 'GET',
        url: `${URL}/getAddress`
    })
}

type ResposneAddress = {

    code: number

}
export type addressParmas = {
    name: string,
    mobile: string,
    address: string
}

export const addAddressAPI = (params: addressParmas) => {
    return request<ResType<ResposneAddress>>({
        method: 'POST',
        url: `${URL}/addAddress`,
        params
    })
}